function Figure_Unit(Folder,SS,IRF)
% load('Result_0_Baseline.mat');
% Folder          =   'TableGraphs\\Baseline\\';
% IRF         =   IRF_Baseline;
% Folder = 'TableGraphs\\Baseline\\';

mkdir(Folder);

% Setup
T_IRF           =   12;
XT              =   0+(0:1:T_IRF)';
List_Shock      =   {'Eps_Eta_M_dom','Eps_Eta_M_ext','Eps_Eta_Y_H','Eps_Eta_p_F',...
                     'Eps_Eta_Z','Eps_Eta_Z_N','Eps_Eta_Z_H'};

%% Aggregate Variables
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
% Graphics
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.18,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);
%--------------------------------------------------------------------------
% Different Figures
%--------------------------------------------------------------------------
% Prices
LabelList   =   {'Real Rate','Nominal Rate','Inflation','Real Exchange Rate'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black');TempFun_LP('--','Gray');...
                 TempFun_LP(':','Blue'); TempFun_LP('-.','Red')};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Rates to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_Pir     =   IRF.(SH).Pir;
    Dev_ir      =   IRF.(SH).ir;
    Dev_rr      =   IRF.(SH).rr_dom;
    Dev_dE      =   IRF.(SH).dE;
    Dev_RealER  =   -IRF.(SH).RelPrice;
    TempIrf     =   [Dev_rr;Dev_ir;Dev_Pir;Dev_RealER]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'Prices_',SH]);
    close(Fig);
end

% Aggregate Demand
LabelList   =   {'Aggregate Consumption','Export'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black');TempFun_LP('--','Blue')};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Demand to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    
    Dev_C       =   IRF.(SH).C;
    Dev_Export  =   IRF.(SH).Export;
    Dev_NetExportIdx=IRF.(SH).NetExportIdx;
    
    TempIrf     =   [Dev_C;Dev_Export]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggDemand_',SH]);
    close(Fig);
end

% Aggregate Supply
LabelList   =   {'Output, Home Tradable Goods','Output, Non-tradable Goods', ...
                 'Import'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black');TempFun_LP('--','Blue');...
                 TempFun_LP('-.','Red')};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Supply to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    
    Dev_Y       =   IRF.(SH).Y;
    Dev_Y_H     =   IRF.(SH).Y_H;
    Dev_Y_N     =   IRF.(SH).Y_N;
    Dev_Import  =   IRF.(SH).Import;
    TempIrf     =   [Dev_Y_H;Dev_Y_N;Dev_Import]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggSupply_',SH]);
    close(Fig);
end

% Consumption Components
LabelList   =   {'C: Home Tradable Goods',...
                 'C: Foreign Tradable Goods',...
                 'C: Non-tradable Goods'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black');TempFun_LP('--','Blue');...
                 TempFun_LP('-.','Red')};
parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Consumption to ',SH],fig_size);
    ax          =   fig_SubPlot(1);

    Dev_C_H     =   IRF.(SH).C_H;
    Dev_C_F     =   IRF.(SH).C_F;
    Dev_C_N     =   IRF.(SH).C_N;
    TempIrf     =   [Dev_C_H;Dev_C_F;Dev_C_N]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'AggConsumption_',SH]);
    close(Fig);
end
%--------------------------------------------------------------------------
% Collect the Key Variables
%--------------------------------------------------------------------------
TempNameList    =   {'Investment','C','Export','Import','Net Export',.... % Aggregate Quantities
                     'Pir','ir','ExchangeRate','UIP Deviation','Relative Price',... % Aggregate Prices
                     'Agg Dom Share','Effective Return for Int HH',... % Portfolio Choices
                     'ConsDist: Std','ConsDiff: RI', 'ConsDiff: FI','ConsDiff: NA' ... % Distributional Concequence
                     };
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    irf         =   IRF.(SH);
  
    [~,MaxIdx]  =   max(abs(IRF.(SH).C));
    TempFun     =   @(irf)irf(MaxIdx);
    TempStatData=   [[TempFun(irf.KI);TempFun(irf.C);TempFun(irf.Export);TempFun(irf.Import);TempFun(irf.NetExportIdx)]*100;....
                     [TempFun(irf.Pir)*4;TempFun(irf.ir)*4;TempFun(irf.ExchangeRate);TempFun(irf.DevUIP)*4;TempFun(irf.RelPrice)]*100;...
                     [TempFun(irf.DomShare_Pos);TempFun(irf.EffReturn_Pos)]*100;...
                     [TempFun(irf.ConsDist.Disp(1,:)); TempFun(irf.C_byRI_N-irf.C_byRI_H); ...
                      TempFun(irf.C_byFI_dom-irf.C_byFI_ext);TempFun(irf.C_byNA_poor-irf.C_byNA_rich) ...
                      ]/abs(TempFun(irf.C)) ...
                     ];
    if ii_Irf==1
        StatDataArray   =   zeros(length(TempNameList),length(List_Shock));
    end
    StatDataArray(:,ii_Irf) ...
                =   TempStatData;
end
IrfStatTable=   array2table(StatDataArray,'RowNames',TempNameList,'VariableNames',List_Shock);

writetable(IrfStatTable,[Folder,'Irf_KeyResults.xlsx'],'WriteRowNames',true);

%--------------------------------------------------------------------------
% Key Price Differential: Wage
%--------------------------------------------------------------------------
LabelList   =   {'H-Wage','N-Wage'};

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Blue');TempFun_LP('--','Red')};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Wages to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_W_H     =   IRF.(SH).w_H;
    Dev_W_N     =   IRF.(SH).w_N;
    TempIrf     =   [Dev_W_H;Dev_W_N]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'PriceDiff_Wage_',SH]);
    close(Fig);
end

%--------------------------------------------------------------------------
% Key Price Differential: Return Rate
%--------------------------------------------------------------------------
LabelList   =   {'Expected Return: Domestic Bond','Expected Return: External Bond'};

parfor ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    Fig         =   FigureSetup(['IRF of Expected Return to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    Dev_ir_dom  =   IRF.(SH).ir_dom;
    Dev_ir_ext  =   IRF.(SH).ir_ext+[IRF.(SH).dE(2:end),0];
    TempIrf     =   [Dev_ir_dom;Dev_ir_ext]*100*4;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
 
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (annualized pp)');
    LEG(PH,LabelList);   

    print('-depsc','-r1000',Fig,[Folder,'PriceDiff_ExpRet_',SH]);
    close(Fig);
end


%% Consumption Difference
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[0.75,1]*1/3; 
fig_gap     =   [0.05,0.08];
fig_VMargin =   [0.10,0.06];
fig_HMargin =   [0.20,0.04]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);

LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Blue'); TempFun_LP('--','Red')};
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
 
    %----------------------------------------------------------------------
    % By Different Characteristics
    %----------------------------------------------------------------------
    Dev_AggStat =   IRF.(SH).AggStat./SS.AggStat;
    Dev_AggStat(abs(Dev_AggStat)<1e-5)  =   0;
    Scale       =   [min(min(Dev_AggStat(1:6,:)));max(max(Dev_AggStat(1:6,:)))]*100;
    % Real Integration
    Fig         =   FigureSetup(['By Real, Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(4,:);Dev_AggStat(3,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Integrated','Non-integrated'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByRI_',SH]);
    close(Fig);
    
    % Financial Integration
    Fig         =   FigureSetup(['By Fin., Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(2,:);Dev_AggStat(1,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Integrated','Non-integrated'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByFI_',SH]);
    close(Fig);
    
    % Rich vs. Poor
    Fig         =   FigureSetup(['By Asset, Consumption Difference to ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    TempIrf     =   [Dev_AggStat(6,:);Dev_AggStat(5,:)]*100;
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'High Net Asset','Low Net Asset'};
    
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(Scale),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter');
    YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConDiff_ByNA_',SH]);
    close(Fig);
end

%% Distribution of Consumption 
%--------------------------------------------------------------------------
% Setup
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.02]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2f'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black');TempFun_LP('--','Blue'); ...
                 TempFun_LP('-.','Red')};
             
SummaryStat =    {'std','p75-p25','p90-p10','std, normalized','p75-p25, normalized','p90-p10, normalized','RI','FI','NA'};
SummaryTable=   zeros(length(SummaryStat),length(List_Shock));
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   TempFun_MaxC(IRF.(SH).C);
    ConsDist    =   IRF.(SH).ConsDist;
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Disp(1,:);ConsDist.Disp(3,:);ConsDist.Disp(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1)*100;
    LabelList   =   {'std','p75-p25','p90-p10'};
    
    Fig         =   FigureSetup(['Deviation Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Level_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Dispersion: Normalized
    %----------------------------------------------------------------------
    TempIrf     =   TempIrf/(MaxAbsC_Val*100);
    
    Fig         =   FigureSetup(['Deviation Dispersion: Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_DevDisp_Normalized_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Gini and Top Shares
    %----------------------------------------------------------------------
    TempIrf     =   [ConsDist.Gini;ConsDist.TopShare(1,:);ConsDist.TopShare(2,:)];
    TempIrf     =   TempIrf(:,1:T_IRF+1);
    LabelList   =   {'Gini','Top Share: 10\%','Top Share: 90\%'};
        
    Fig         =   FigureSetup(['Level Dispersion, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                     'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                     'AxisProperty',AxisSetup);
    XLabel('Quarter'); YLabel('Deviation from steady state (pp)');
    LEG(PH,LabelList);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_LevelDisp_',SH]);
    close(Fig);
    %----------------------------------------------------------------------
    % Variance Decomposition
    %----------------------------------------------------------------------
    TempIrfList =   {'RI','FI','NA','RI_FI','RI_NA','FI_NA','RI_FI_NA','NA_Fine','z'};
    TempIrf     =   zeros(length(TempIrfList),size(ConsDist.VarDec.RI,2));
    for jj=1:length(TempIrfList)
        TempIrf(jj,:)   =   ConsDist.VarDec.(TempIrfList{jj})(1,:);
    end
    TempIrf     =   TempIrf(:,MaxAbsC_Idx);
    TempTable   =   array2table(round(TempIrf,3),'VariableNames',{'WithinGroup'},...
                                                 'RowNames',TempIrfList);
    writetable(TempTable,[Folder,'Irf_VarDec.xlsx'],'WriteRowNames',true,'Sheet',SH);
    %----------------------------------------------------------------------
    % Summary Table
    %----------------------------------------------------------------------
    
    TempIrf_1   =   [ConsDist.Disp(1,:);ConsDist.Disp(3,:);ConsDist.Disp(2,:)];
    TempIrf_2   =   [ConsDist.VarDec.RI(2,:);ConsDist.VarDec.FI(2,:);ConsDist.VarDec.NA_Fine(2,:)];
    TempIrf     =   [TempIrf_1(:,MaxAbsC_Idx);...
                     TempIrf_1(:,MaxAbsC_Idx)/MaxAbsC_Val;...
                     TempIrf_2(:,MaxAbsC_Idx)];
    
    SummaryTable(:,ii_Irf) ...
                =   TempIrf;
end
SummaryTable    =   array2table(SummaryTable, ...
                                'VariableNames',List_Shock,...
                                'RowNames',SummaryStat);
writetable(SummaryTable,[Folder,'ConsDispSummary.xlsx'],'WriteRowNames',true);

%% Appendix
VarDict     =   struct('C','Consumption','C_N','Consumption: N','C_H','Consumption: H','C_F','Consumption: F',...
                       'L_N','Hours: N','L_H','Hours: H','w_N','Wage: N','w_H','Wage: H',......
                       'Y','Output','Y_N','Output: N','Y_H','Output: H','dE','Depreciation',...
                       'ir','Domestic Nominal Rate','ir_s','Foreign Nominal Rate','AggDomesticAsset','Total Domestic Bond','AggForeignAsset','Total Foreign Bond',...
                       'Pir','Inflation','Pir_N','Inflation: N','Pir_H','Inflation: H','Pir_F','Inflation: F', ...
                       'EffReturn_Pos','Nominal Return: Int. Saver','EffReturn_Neg','Nominal Return: Int. Borrower','DomShare_Pos','Porfolio: Int. Saver','DomShare_Neg','Portfolio: Int. Borrower', ...
                       'DevUIP','Deviation of UIP','RelPrice','Relative Price' ...
                       );
% 'Eta_M_dom','MP: Domestic','Eta_M_ext','MP: Foreign','Eta_Y_H','Demand: Foreign'
% 'Eta_Z','TFP','Eta_Z_N','TFP: N','Eta_Z_H','TFP: H',...'dE_Real','Real Exchange', ...
% 'Bp_dom','Saving: Domestic','Bp_ext','Saving: Foreign',
% 'E','CAD/USD','CPI','CPI', 'T','Transfer','TAU','Tax Rate','B','Gov. Bond','Profit','Profit' ...
                       
VarList     =   fieldnames(VarDict);

% Graph
Num_Var     =   length(VarList);
Num_Shock   =   length(List_Shock);

N_col       =   4;
N_row       =   ceil(Num_Var/N_col);
fig_size    =   [N_col,N_row].*[1,0.75]*1/4;  
fig_gap     =   [0.04,0.03];
fig_VMargin =   [0.03,0.03];
fig_HMargin =   [0.03,0.01]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
                                 
AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2g'),...
                        'FontSize',struct('X',6,'Y',6),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',4).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',1).Setup(Y);

TempFun_LP  =   @(S,C)GR_Line('Style',S,'Color',MyColor(C),'Width',3);
List_LP     =   {TempFun_LP('-','Black')};
             
for ii_sh=1:Num_Shock
    SH          =   List_Shock{ii_sh};
    fig_Handle  =   FigureSetup(['IRF-',SH],fig_size);
    for ii_vv=1:Num_Var
        VV              =   VarList{ii_vv};
        ax              =   fig_SubPlot(ii_vv);
        if strcmp(VV,'dE_Real')
            TempIrf         =   IRF.(SH).dE-IRF.(SH).Pir;
        elseif strcmp(VV,'E')
            TempIrf         =   cumsum(IRF.(SH).dE);
        elseif strcmp(VV,'CPI')
            TempIrf         =   cumsum(IRF.(SH).Pir);
        else
            TempIrf         =   IRF.(SH).(VV);
        end
        TempIrf(abs(TempIrf)<1e-6)  =   0;
        AxisSetup.Exponent  =   struct('X',0,'Y',floor(log(max(max(abs(TempIrf(:))),1e-7))/log(10)));
        [PH,ax]     =   Plot_IRF(TempIrf,'ax',ax,'LineProperty',List_LP,...
                                 'XTick',Tick_X(XT),'YTick',Tick_Y(TempIrf),...
                                 'AxisProperty',AxisSetup,'Symmetric',1);
        title(VarDict.(VV),'fontsize',8,'interpreter','latex');

    end

    print(fig_Handle,[Folder,'Full_',SH],'-depsc'); 
    close(fig_Handle);
end

%% Distributional Effects
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1.05,0.80]*1/2.5; 

AxFontSize  =   8;
TickFmt     =   '%.2f';
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');
LineStyle   =   {'-','--','-.';'b','r','m';2,2,2};
%--------------------------------------------------------------------------
% Webplot, by FI x RI
%--------------------------------------------------------------------------
fig_gap     =   [0.00,0.00];
fig_VMargin =   [0.00,0.00];
fig_HMargin =   [0.00,0.00]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);

LEG         =   @(LabelList)legend(LabelList,'fontsize',AxFontSize,'interpreter','latex',...
                                                'location','southoutside','Orientation','Vertical');

% Separated
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    % Normalized
    Fig         =   FigureSetup(['Web Plot, Distributional Effect by FI x RI, Normalized'],fig_size);
    ax          =   fig_SubPlot(1);
    TempFun_WebPlot({IRF.(SH)});
%     LEG('Benchmark');
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByFIxRI_',SH]);
    close(Fig);
    
    Fig         =   FigureSetup(['Web Plot, Distributional Effect by FI x RI, Normalized, Simplified'],fig_size);
    ax          =   fig_SubPlot(1);
    TempFun_WebPlot_4Dim({IRF.(SH)});
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByFIxRI_Simplified_',SH]);
    close(Fig);
end

%--------------------------------------------------------------------------
% Line-plot, by NA
%--------------------------------------------------------------------------
N_col       =   1;
N_row       =   1;
fig_size    =   [N_col,N_row].*[1,0.75]*1/2.5; 
fig_gap     =   [0.02,0.02];
fig_VMargin =   [0.15,0.02];
fig_HMargin =   [0.15,0.05]; 

fig_SubPlot =   @(ii_vv)subtightplot(N_row,N_col,ii_vv,...
                                     fig_gap,fig_VMargin,fig_HMargin);
LEG         =   @(PH,LabelList)legend(PH,LabelList,'fontsize',8,'interpreter','latex','location','best');
XLabel      =   @(Label)xlabel(Label,'fontsize',8,'interpreter','latex');
YLabel      =   @(Label)ylabel(Label,'fontsize',8,'interpreter','latex');

AxisSetup   =   GR_Axis('TickFmt',struct('X','%g','Y','%.2f'),...
                        'FontSize',struct('X',8,'Y',8),...
                        'Exponent',struct('X',0,'Y',0),...
                        'Box','off');

Tick_X      =   @(X)GR_TickValue('Unit',1).Setup(X);
Tick_Y      =   @(Y)GR_TickValue('Symmetric',0).Setup(Y);

TempLine    =   GR_Line('Style','-','Color',MyColor('Blue'),'Width',3);
for ii_Irf=1:length(List_Shock)
    SH          =   List_Shock{ii_Irf};
    [MaxAbsC_Val,MaxAbsC_Idx] ...
                =   TempFun_MaxC(IRF.(SH).C);
    ConsDist    =   IRF.(SH).ConsDist;
    %----------------------------------------------------------------------
    % Dispersion
    %----------------------------------------------------------------------
    TempIrf     =   ConsDist.AvgDev_byNA(:,MaxAbsC_Idx)'/MaxAbsC_Val;
    
    Fig         =   FigureSetup(['Line Plot, Distributional Effect by NA, Normalized, ',SH],fig_size);
    ax          =   fig_SubPlot(1);
    XAxis       =   (1:1:size(ConsDist.AvgDev_byNA,1))';
    PH          =   TempLine.Plot(ax,XAxis,TempIrf);
    ax.YTick    =   Tick_Y(TempIrf);
    ax.XTick    =   XAxis;
    hline       = refline(0,1); 
    hline.Color = MyColor('Black');
    ax.XLim     =   [min(XAxis),max(XAxis)];
    ax.XTickLabel=  {'$\leq Q_{20}$', '$(Q_{20},Q_{40}]$', '$(Q_{40},Q_{60}]$', '$(Q_{60},Q_{80}]$', '$>Q_{80}$'};
    ax.TickLabelInterpreter = 'latex';
    XLabel('Net Wealth'); YLabel('Average Consumption Response');
    AxisSetup.Setup(ax);
    
    print('-depsc','-r1000',Fig,[Folder,'ConsDist_AvgDevByNA_',SH]);
    close(Fig);
end
